﻿using UnityEngine;
using System.Collections;
using System;

namespace UI
{
    public class RecycleSelectItemBase : MonoBehaviour 
    {
        public GameObject checkMark;

        public virtual void Init(object value, UIEventListener.VoidDelegate callback)
        {
            SetData(value);
            SetOnClickCallback(callback);
        }

        protected virtual void SetData(object value) { }

        public virtual int GetQuality()
        {
            return 0;
        }

        public virtual int GetBreachLevel()
        {
            return 0;
        }

        public virtual int GetLevel()
        {
            return 0;
        }

        public virtual int GetId()
        {
            return 0;
        }



        bool _isSelected = false;
        public bool IsSelected
        {
            get { return _isSelected; }
        }

        public void Select(bool select)
        {
            _isSelected = select;
            checkMark.SetActive(_isSelected);
        }

        public virtual string GetItemGUID() {
            return "";
        }

        UIEventListener.VoidDelegate onClick;

        protected void SetOnClickCallback(UIEventListener.VoidDelegate _onclick)
        {
            onClick = _onclick;
        }

        void OnClick()
        {
            if (onClick != null)
            {
                onClick(gameObject);
            }

        }

    }
}
